package com.chenwut.test1;
import java.util.Scanner;

public class Main5 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt(); // 测试用例数量
        for (int i = 0; i < t; i++) {
            int n = scanner.nextInt(); // 字符串数量
            String[] strs = new String[n]; // 存放字符串的数组
            for (int j = 0; j < n; j++) {
                strs[j] = scanner.next();
            }
            int[] result = solve(strs); // 解题
            for (int j = 0; j < n; j++) {
                System.out.print(result[j] + " ");
            }
            System.out.println();
        }
        scanner.close();
    }

    public static int[] solve(String[] strs) {
        int[] result = new int[strs.length];
        for (int i = 0; i < strs.length; i++) {
            String si = strs[i];
            boolean flag = false;
            for (int j = 0; j < strs.length; j++) {
                if (i != j) { // 如果字符串i与j不是同一个字符串
                    String sj = strs[j];
                    for (int k = 0; k < strs.length; k++) {
                        if (i != k && j != k) { // 如果字符串i,j,k不是同一个字符串
                            String sk = strs[k];
                            if (sj.concat(sk).equals(si) || sk.concat(sj).equals(si)) {
                                // 如果存在si=sj+sk或si=sk+sj，则表示满足关系
                                result[i] = 1;
                                flag = true;
                                break;
                            }
                        }
                    }
                    if (flag) {
                        break;
                    }
                }
            }
        }
        return result;
    }
}